<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>还款明细</title>
    <!--1.引入bootstrap框架的样式； -->
    <link rel="stylesheet" href="../../../bootstrap/css/bootstrap.min.css">
    <!--2.引入angularJS框架的样式； -->
    <link rel="stylesheet" href="../../../angularjs/pagination.css">
    <!--3.引入Layer样式； -->
    <link rel="stylesheet" href="../../../layer/layer/theme/default/layer.css">
    <!--4.引入jquery框架-->
    <script src="../../../bootstrap/js/jquery.min.js"></script>
    <!--5.引入boostrap框架的JS-->
    <script src="../../../bootstrap/js/bootstrap.min.js"></script>
    <!--6.引入Layer框架的JS-->
    <script src="../../../layer/layer/layer.js"></script>
    <!--7.引入angularJS框架-->
    <script src="../../../angularjs/angular.min.js"></script>
    <!--8.引入angularJS的分页框架-->
    <script src="../../../angularjs/pagination.js"></script>
    <script>
        var app=angular.module("myApp",['pagination']);
        app.controller("myCtrl",function ($scope,$http) {
            //分页属性配置
            $scope.paginationConf = {
                currentPage:1,
                itemsPerPage:5,
                totalItems:1000,
                perPageOptions:[2,5,10,20,50],
                onChange:function () {
                    $scope.searchAll($scope.paginationConf.currentPage,$scope.paginationConf.itemsPerPage);
                }
            };
            //带分页
            $scope.searchAll=function (pageIndex,pageSize) {

                $http.post("/billdetil/list?pageIndex="+pageIndex+"&pageSize="+pageSize+"&cardnum="+$("#cardnum").val()+"&month="+$("#month").val()).success(function (data) {
                    $scope.list=data.datas;
                    $scope.paginationConf.totalItems=data.totalNum;

                })
            };
            $scope.searchAll2=function () {
                $scope.searchAll($scope.paginationConf.currentPage,$scope.paginationConf.itemsPerPage)
            };
            //千分位分隔符,并保留两位小数格式化
            $scope.qianfenwei=function(obj){//输入obj=123456.7890
                var mnyReg = /^([1-9][0-9]*|(([0]\.[0-9]{0,2}[1-9]\d*|[1-9][0-9]*\.\d*)))$/;//根据需求修改
                // if(!(mnyReg.test(obj))){
                //     layer.msg("请输入正确的资金",{time:1000});
                //     return;
                // }
                var n = 2; //保留得小数位
                obj = parseFloat(obj).toFixed(n); //obj=123456.789
                var left = obj.split(".")[0].split("").reverse();//left = ["6","5","4","3","2","1"]
                var right = obj.split(".")[1]; //right = "789"
                var total = new Array();
                for (i = 0; i < left.length; i++) {
                    total.push(left[i]);
                    if((i + 1) % 3 == 0 && (i + 1) != left.length){
                        total.push(",");
                    }
                } //total = ["6","5","4",",","3","2","1"]
                if (total.reverse().join("")!=null&&total.reverse().join("")!="") {
                    return total.reverse().join("") + "." + right;
                }else {
                    return 0.00;
                }
            }

        })
    </script>

</head>
<body>
<div class="container">
    <div class="panel panel-info" id="pa">
        <div class="panel-heading" id="head">
            <h1 id="hl" style="color: black">账单明细
                <span style=" color: #3cd3d3; float: right"></span>
            </h1>
        </div>
        <div class="panel-body" ng-app="myApp" ng-controller="myCtrl" ng-init="searchAll2()" >
            <form class="form-inline">
                信用卡号: <input type="text" class="form-control"   id="cardnum">
                账单月份: <input type="month" class="form-control"  id="month" >
                <button class="btn-success" ng-click="searchAll2()" style="font-size: 18px">查询</button>
            </form>
            <table class="table text-center table-striped table-responsive table-bordered table-condensed">
                <tr>
                    <td>序号</td>
                    <td>账单编号</td>
                    <td>信用卡号</td>
                    <td>账单时间</td>
                    <td>账单总金额</td>
                    <td>账单状态</td>
                    <td>应还款日期</td>
                    <td>账单通知方式</td>
                    <td>操作</td>
                </tr>
                <tr ng-repeat="s in list">
                    <td>{{$index+1}}</td>
                    <td>{{s.billid}}</td>
                    <td>{{s.cardnum}}</td>
                    <td>{{s.billcreate}}</td>
                    <td><input type="text" style="border: none" ng-value="qianfenwei(s.billmoney)" readonly></td>
                    <td>{{s.billstatus}}</td>
                    <td>{{s.billrepaytime}}</td>
                    <td>{{s.billproduce}}</td>
                    <td><a class="btn btn-success" ng-href="/billdetil/repayment?billid={{s.billid}}">快速还款</a></td>
                </tr>
                <tr>
                    <td colspan="10">
                        <tm-pagination conf="paginationConf"></tm-pagination>
                    </td>
                </tr>
            </table>

        </div>
    </div>
</div>

</body>
<script>
    //千分位分隔符,并保留两位小数格式化
    function qianfenwei(obj){//输入obj=123456.7890
        var mnyReg = /^([1-9][0-9]*|(([0]\.[0-9]{0,2}[1-9]\d*|[1-9][0-9]*\.\d*)))$/;//根据需求修改
        if(!(mnyReg.test(obj))){
            layer.msg("请输入正确的资金",{time:1000});
            return;
        }
        var n = 2; //保留得小数位
        obj = parseFloat(obj).toFixed(n); //obj=123456.789
        var left = obj.split(".")[0].split("").reverse();//left = ["6","5","4","3","2","1"]
        var right = obj.split(".")[1]; //right = "789"
        var total = new Array();
        for (i = 0; i < left.length; i++) {
            total.push(left[i]);
            if((i + 1) % 3 == 0 && (i + 1) != left.length){
                total.push(",");
            }
        } //total = ["6","5","4",",","3","2","1"]
        return total.reverse().join("") + "." + right;
    }
    //去千分位分隔符
    function quqianfenwei(oldMny){
        oldMny=oldMny.replace(/,/g, '');
        return oldMny;
    }
</script>
</html>